package com.example.weathersuggestion;

import java.util.ArrayList;
import java.util.List;
import java.util.*;

public class ActivitySuggestion extends Suggestion{
	private List<String> activityList;
	
	double precipPercent = 0;
	long longTemp = 0;
	int index=-1; //default
	private ArrayList<String> returnedList = new ArrayList<String>();
	
	public ActivitySuggestion(){
		
		//index relates to temp when doing calc
		activityList = new ArrayList<String>();
		activityList.add(0,"Have a hot coco by the fireside.");
		activityList.add(1,"Bundle up in blankets and read a book.");
		activityList.add(2,"Workout at home.");
		activityList.add(3,"Not a bad day for a run around the block");
		activityList.add(4,"Great day for a run or a bike ride.");
		activityList.add(5,"Take a trip to the gym.");
		activityList.add(6,"Go hiking on park trails.");
		activityList.add(7,"Have a picnic with friends.");
		activityList.add(8,"Take a trip to an amusement park.");
		activityList.add(9,"Go swimming or fishing.");
		activityList.add(10,"Relax indoors with some iced tea and movies.");
		activityList.add(11,"Go iceskating on the lake.");
		activityList.add(12,"Play some video games.");
		activityList.add(13,"Movie marathon.");
		activityList.add(14,"Jog around the block");
		activityList.add(15,"Clean around the house.");
		activityList.add(16,"Visit friends.");
		activityList.add(17,"Go to the zoo.");
		activityList.add(18,"Go to the park.");
		activityList.add(19,"Take friends on a road trip.");
		activityList.add(20,"Throw a pool party.");
		activityList.add(21,"Turn up the ac and prank call your friends.");
		
	}
	
	@Override
	public ArrayList<String> getSuggestion(Double tempStr, Double precipStr){
		returnedList = new ArrayList<String>();
		//handle strings
		setTemp(tempStr);
		precipPercent = precipStr;
		//precipPercent = Integer.parseInt(precipStr);
		int temp_int = tempStr.intValue();
		index = (int)(temp_int*.1);
		//Convert double to long -> Can't go straight from double to int
		//Round method casts temp as long
		//longTemp = Math.round(getTemp());
		//long to int (to get index)
		//index = (int)(longTemp*.1);
		
		
		
		//convert precipitation from double percentage to boolean (yes/no)
		if(precipPercent < 50 && precipPercent >= 0){
			setPrecip(false);
		}
		else if(precipPercent >= 50 && precipPercent <= 100){
			setPrecip(true);
		}
		else{
			//return "Precipitation can't be resolved to boolean. Out of bounds (0-100)\nPercent val passed: " + precipPercent;
		}
		
		//Return index 0 if temp is less than 0
		if(temp_int < 0)
		{
			returnedList.add(activityList.get(0));
		}
		
		//Return index 10 if temp is greater than  or equal to 105
		if(temp_int >= 105)
		{
			returnedList.add(activityList.get(10));
		}
		
		
		
		//Generate a 0 or 1
		Random generator = new Random();
		int randomIndex = generator.nextInt( 2 );
		
		//if 1 is generated add 11 to index
		if(randomIndex == 1)
		{
			index += 11;
		}
		
		//find suggestions if precipitation is likely
		if(!(getPrecip())){
			returnedList.add(activityList.get(index));
		}
		else{
			returnedList.add(activityList.get(index)+"\nBe aware of precipitation");			
		}
		return returnedList;
	}	
}
